package com.limingru.online_class.controller;

import com.limingru.online_class.common.Result;
import com.limingru.online_class.common.ResultGenerator;
import com.limingru.online_class.common.exception.CommonException;
import com.limingru.online_class.domain.Video;
import com.limingru.online_class.domain.VideoBanner;
import com.limingru.online_class.domain.vo.VideoVO;
import com.limingru.online_class.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/v1/pub/video")
public class VideoController {

    @Autowired
    VideoService videoService;

    /**
     * 轮播图列表
     * @return
     */
    @GetMapping("list_banner")
    public Result listVideoBanners() {
        List<VideoBanner> videoBanners = videoService.listBanner();
        return ResultGenerator.generateSuccessResult(videoBanners);
    }

    @GetMapping("list")
    public Result<List<Video>> listAll() {
        return ResultGenerator.generateSuccessResult(videoService.findAllVideos());
    }

    @GetMapping("find_video_detail_by_id")
    public Result<VideoVO> findVideoDetailById(@RequestParam(value = "videoId" ,required = true) int videoId) {
        VideoVO video = videoService.findVideoDetailByVideoId(videoId);
        return ResultGenerator.generateSuccessResult(video);
    }
}
